package com.hskn.hss.utils;

import com.hskn.hss.module.tlthreshold.entity.TlThreshold;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
@Slf4j
@Component
public class WorkUtil {
    /**
     * 根据坐标点获取加油量
     * list 坐标点集合
     */

    public Double getAddOilMess(List<Double> list){
        double seuil = 0.5;
        double addOilMass = 0;
        for (int i = 1; i< list.size(); i++){
            if (list.get(i) - list.get(i-1) > seuil){
                addOilMass += list.get(i) - list.get(i-1);
            }
        }
        return addOilMass;
    }

    public TlThreshold getThresholdByName(List<TlThreshold> tlThresholdList, String systemName){
        for (TlThreshold tlThreshold : tlThresholdList) {
            if (systemName.equals(tlThreshold.getSysname())){
                return tlThreshold;
            }
        }
        return null;
    }
}
